import React from 'react'
import { Select } from 'antd'
const Option  = Select.Option

export default {
    formateDate(time) {
        if (!time) return '';
        let date = new Date(time)
        return date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds()
    },
    pagination(data, callback) {
        return {
            onChange: (current) => {
                callback(current)
            },
            current: data.result.page,
            pageSize: data.result.page_size,
            total: data.result.total_count,
            showTotal: () => {
                return `共${data.result.total_count}条`
            },
            simple: false,
            showQuickJumper: true
        }
    },
    getOptionList(data) {
        if (!data) {
            return []
        }
        let optionList = []
        data.map((item, index) => {
            optionList.push(<Option key={index} value={item.id}>{item.name}</Option>)
        })
        return optionList
    },
    updataSelectedItem(selectedRowKeys, selectedRows){
        this.setState({
            selectedRowKeys,
            selectedRows
        })
    }
}